package com.leoandroid.tool.toolsbox.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.leoandroid.tool.toolsbox.largeread.R
import com.leoandroid.tool.toolsbox.largeread.databinding.AdapterChengyuBinding

class ChengYuAdapter(val context:Context,val dataList:ArrayList<String>): RecyclerView.Adapter<ChengYuAdapter.Holder>() {

    inner class Holder(itemview: View):RecyclerView.ViewHolder(itemview){

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val inflate = DataBindingUtil.inflate<AdapterChengyuBinding>(LayoutInflater.from(context), R.layout.adapter_chengyu,parent,false)
        return Holder(inflate.root)
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
        val dataBind: AdapterChengyuBinding? = DataBindingUtil.getBinding<AdapterChengyuBinding>(holder.itemView)
        dataBind?.apply {
            chengyuTv.text = dataList[position].toString()
        }
    }

    override fun getItemCount(): Int {
        return dataList.size
    }
}